package com.example.kiratest.EasyExcel.Config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class ExcelThreadPoolConfig {

    public static final int CORE_POOL_SIZE = 6;//核心线程数
    public static final int MAX_POOL_SIZE = 12;//最大线程数
    public static final int QUEUE_CAPACITY = 100;//队列的最大数量
    public static final Long KEEP_ALIVE_TIME = 1L;//保持连接的时间

    @Bean("EasyExcelThreadPool")
    public ThreadPoolExecutor EasyExcelThreadPool(){
         ThreadPoolExecutor EasyExcelThreadPool = new ThreadPoolExecutor(
                CORE_POOL_SIZE,
                MAX_POOL_SIZE,
                KEEP_ALIVE_TIME,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(QUEUE_CAPACITY),
                new ThreadPoolExecutor.AbortPolicy()
        );
         return EasyExcelThreadPool;
    }

}
